package String;

import java.util.StringJoiner;

public class String_joiner {
    public static void main(String[] args) {
        //创建一个对象1
        StringJoiner sj=new StringJoiner(",","[","]");//第一个符号是加在中间的，后面两个是起止符号

        int []a={1,2,3};
        for(int i=0;i<a.length;i++)
        {
            sj.add(a[i]+"");
        }
        System.out.println(sj.toString());




        //2
        StringJoiner sj1=new StringJoiner("---");//中间的连接符号

        //添加元素
        sj1.add("aaa").add("bbb").add("ccc");
        System.out.println(sj1);




        //3
        StringJoiner sj2=new StringJoiner(",","=",".");

        sj2.add("aaa").add("bbb").add("ccc");

        int len=sj2.length();
        System.out.println(len);

        System.out.println(sj2);//=aaa,bbb,ccc.
        String str=sj2.toString();
        System.out.println(str);//=aaa,bbb,ccc.



    }
}
